function loadImg(src) {
  return new Promise((resolve, reject) => {
    const img = document.createElement("img");
    img.onload = () => {
      resolve(img);
    };
    img.onerror = () => {
      const err = new Error(`img faild ${src}`);
      reject(err);
    };
    img.src = src;
  });
}

const url1 =
  "https://fanyi-cdn.cdn.bcebos.com/static/translation/img/header/logo_40c4f13.svg";
const url2 = "https://scpic.chinaz.net/files/pic/pic9/202101/apic30496.jpg";
loadImg(url1)
  .then((img) => {
    console.log(img.width);
    return { hh: "111" }; // 可以返回一个常量
  })
  .then((obj) => {
    console.log(obj);
    return loadImg(url2); // 返回新的Promise对象
  })
  .then((img2) => {
    console.log(img2.width);
  });
